<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://ckfinder.com" prefix="ckfinder" %>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>

<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <logic:lessThan name="saleForm" property="saleID" value="1">
            <h2>Add Sale</h2>
        </logic:lessThan>
        <logic:greaterThan name="saleForm" property="saleID" value="0">
            <h2>Edit Sale "<bean:write name="saleForm" property="saleID"/>"</h2>
        </logic:greaterThan>
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleClass="validate-form" action="admin/sale.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <h2>Flat</h2><br/>
            <html:hidden property="flatID"/>
            <p>
                <label>ID: </label>
                <span class="text"><bean:write name="flat" property="flatID"/></span>
            </p>
            <p>
                <label>Flat Name: </label>
                <span class="text"><bean:write name="flat" property="flatName"/></span>
            </p>
            <p>
                <label>Floor Number: </label>
                <span class="text"><bean:write name="flat" property="floorNumber"/></span>
            </p>
            <p>
                <label>Area: </label>
                <span class="text"><bean:write name="flat" property="area"/>
                &nbsp;sq.foot</span>
            </p>
            <hr/>
            <br/><br/>
            <h2>Sale</h2><br/>
            <logic:greaterThan name="saleForm" property="saleID" value="0">
                <p><label>Sale ID: </label><span class="text"><bean:write name="saleForm" property="saleID"/></span></p>
            </logic:greaterThan>
            <p>
                <html:hidden property="saleID" />
                <logic:lessThan name="saleForm" property="saleID" value="1">
                    <label for="paymentMode">Payment Mode:</label><span class="required">*</span><br/>
                    <logic:iterate id="paymentMode" name="paymentModeList">
                        <html:radio styleClass="required" property="paymentMode" value="${paymentMode[0]}"/> <label>${paymentMode[1]}</label>
                        &nbsp;&nbsp;&nbsp;&nbsp;<span class="note">${paymentMode[2]}</span><br/>
                    </logic:iterate>
                    <br/>
                    <label for="paymentMode" class="error" generated="true" style="display:none;"></label>
                </logic:lessThan>
                <logic:greaterThan name="saleForm" property="saleID" value="0">
                    <label>Payment Mode:</label>&nbsp;<span class="text"><bean:write name="saleForm" property="paymentModeName"/></span>
                </logic:greaterThan>   
            </p>
            <p>
                <label for="customerName">Customer Name:</label><span class="required">*</span><br/>
                <html:text styleId="customerName" styleClass="text small required" property="customerName"/>
            </p>
            <p>
                <label for="customerPhone">Customer Phone:</label><span class="required">*</span><br/>
                <html:text styleId="customerPhone" styleClass="text small required" property="customerPhone"/>
            </p>
            <p>
                <label for="customerAddress">Customer Address:</label><span class="required">*</span><br/>
                <html:text styleId="customerAddress" styleClass="text small required" property="customerAddress"/>
            </p>
            <p>
                <label>Description:</label><br/>
                <html:textarea property="description"/>
                <ckfinder:setupCKEditor basePath="/ckfinder/" editor="description"  />
                <ckeditor:replace basePath="/ckeditor/" replace="description" />
            </p>  
            
            <hr/>
            
            <p>
                <html:submit property="action" value="Save" styleClass="submit small"/>    
                <logic:greaterThan name="saleForm" property="saleID" value="0">
                    <html:submit property="action" value="Save & Exit" styleClass="submit mid"/>
                    <html:link styleClass="confirm-button submit small red" action="/admin/saleListing.do?action=delete" paramId="saleID" paramName="saleForm" paramProperty="saleID">
                        Delete
                    </html:link>
                </logic:greaterThan>
                <html:link action="/admin/saleListing.do" styleClass="submit small gray">Cancel</html:link>
            </p>
            
            
        </div>
        <!-- .block_content ends -->
    </html:form>
        
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->
